import http from '@/http'
import { CostPricingPlanListParam, CostPricingPlanBatchUpdateStatusDto, CostPricingPlanBatchCopyDto } from './type'

/**
 * 查询成本核价方案列表
 */
export const queryCostPlanListApi = (params: CostPricingPlanListParam) => {
  return http.get('/costPricingPlan/queryCostPlanList', params)
}

/**
 * 根据ID获取成本核价方案详情
 */
export const getCostPricingPlanApi = (id: number) => {
  return http.get(`/costPricingPlan/getCostPricingPlan/${id}`)
}

/**
 * 新增成本核价方案
 */
export const saveCostPricingPlanApi = (data: any) => {
  return http.post('/costPricingPlan/saveCostPricingPlan', data)
}

/**
 * 更新成本核价方案
 */
export const updateCostPricingPlanApi = (data: any) => {
  return http.put('/costPricingPlan/updateCostPricingPlan', data)
}

/**
 * 删除成本核价方案
 */
export const deleteApi = (id: number) => {
  return http.delete(`/costPricingPlan/deleteCostPricingPlan/${id}`)
}

/**
 * 更新成本核价方案状态
 */
export const updateStatusApi = (data: { id: number; activate: number }) => {
  return http.put('/costPricingPlan/updateStatus', data)
}

/**
 * 批量更新成本核价方案状态
 */
export const batchUpdateStatusApi = (data: CostPricingPlanBatchUpdateStatusDto) => {
  return http.put('/costPricingPlan/batchUpdateStatus', data)
}

/**
 * 批量复制成本核价方案
 */
export const batchCopyApi = (data: CostPricingPlanBatchCopyDto) => {
  return http.post('/costPricingPlan/batchCopy', data)
}

/**
 * 导出成本核价方案
 */
export const exportCostPlanApi = (params: CostPricingPlanListParam) => {
  return http.get('/costPricingPlan/export', params, { responseType: 'blob' })
}

/**
 * 自定义导出成本核价方案
 */
export const exportCustomCostPlanApi = (data: any) => {
  return http.post('/costPricingPlan/exportCustom', data, { responseType: 'blob' })
}

/**
 * 获取成本模板
 */
export const getCostTemplateApi = (data: any) => {
  return http.post('/costPricingPlan/getCostTemplate', data)
}

/**
 * 获取额外成本详情
 */
export const getExtraCostDetailApi = (data: any) => {
  return http.post('/costPricingPlan/getExtraCostDetail', data)
}

/**
 * 获取成本核价方案详情（用于表单）
 */
export const getSoftwarePlanApi = (id: string | number) => {
  return http.get(`/costPricingPlan/getCostPricingPlan/${id}`)
}

/**
 * 新增成本核价方案（用于表单提交）
 */
export const submitCreateCostPricingPlanApi = (data: any) => {
  return http.post('/costPricingPlan/saveCostPricingPlan', data)
}

/**
 * 更新成本核价方案（用于表单提交）
 */
export const submitUpdateCostPlan = (data: any) => {
  return http.put('/costPricingPlan/updateCostPricingPlan', data)
}